<template>
  <el-card>
    <span slot="header">编辑订单</span>
    <el-form :model="formData" label-width="80px">
      <el-form-item label="订单id">
        <el-input v-model="formData.id"></el-input>
      </el-form-item>
      <el-form-item label="订单号">
        <el-input v-model="formData.orderNo"></el-input>
      </el-form-item>
      <el-form-item label="下单时间">
        <el-input v-model="formData.orderTime"></el-input>
      </el-form-item>
      <el-form-item label="联系电话">
        <el-input v-model="formData.phone"></el-input>
      </el-form-item>
      <el-form-item label=" 收货人">
        <el-input v-model="formData.consignee"></el-input>
      </el-form-item>
      <el-form-item label="送货地址">
        <el-input v-model="formData.deliverAddress"></el-input>
      </el-form-item>
      <el-form-item label="送达时间">
        <el-input v-model="formData.deliveryTime"></el-input>
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="formData.remarks"></el-input>
      </el-form-item>
      <el-form-item label="订单金额">
        <el-input v-model="formData.orderAmount"></el-input>
      </el-form-item>
      <el-form-item label="订单状态">
        <el-input v-model="formData.orderState"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="saveEdit">保存</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script>
import { getOrderDetailReq, editOrderReq } from "@/api/order";

export default {
  data() {
    return {
      id: "",
      formData: {},
    };
  },
  methods: {
    async getData() {
      let res = await getOrderDetailReq({ id: this.id });
      // let res = await editOrderReq({ id: this.id });
      // console.log("res :>> ", res);
      this.formData = res.data.data;
    },
    async saveEdit() {
      let deliveryTime=this.formData.deliveryTime
      // console.log("id :>> ", id);
      let res = await editOrderReq({ ...this.formData, id:this.id });
      // console.log("res :>> ", res);
    },
  },
  created() {
    //获取动态路由传参---params
    this.id = this.$route.params.id;
    // console.log("id :>> ", id);
    this.getData();
  },
};
</script>

<style lang="scss" scoped></style>
